package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Tudijiaoguan;
import com.ruoyi.system.service.ITudijiaoguanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 土地浇灌Controller
 * 
 * @author ruoyi
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/system/tudijiaoguan")
public class TudijiaoguanController extends BaseController
{
    @Autowired
    private ITudijiaoguanService tudijiaoguanService;

    /**
     * 查询土地浇灌列表
     */
    @PreAuthorize("@ss.hasPermi('system:tudijiaoguan:list')")
    @GetMapping("/list")
    public TableDataInfo list(Tudijiaoguan tudijiaoguan)
    {
        startPage();
        List<Tudijiaoguan> list = tudijiaoguanService.selectTudijiaoguanList(tudijiaoguan);
        return getDataTable(list);
    }

    /**
     * 导出土地浇灌列表
     */
    @PreAuthorize("@ss.hasPermi('system:tudijiaoguan:export')")
    @Log(title = "土地浇灌", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Tudijiaoguan tudijiaoguan)
    {
        List<Tudijiaoguan> list = tudijiaoguanService.selectTudijiaoguanList(tudijiaoguan);
        ExcelUtil<Tudijiaoguan> util = new ExcelUtil<Tudijiaoguan>(Tudijiaoguan.class);
        util.exportExcel(response, list, "土地浇灌数据");
    }

    /**
     * 获取土地浇灌详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tudijiaoguan:query')")
    @GetMapping(value = "/{tudijiaoguanId}")
    public AjaxResult getInfo(@PathVariable("tudijiaoguanId") Long tudijiaoguanId)
    {
        return success(tudijiaoguanService.selectTudijiaoguanByTudijiaoguanId(tudijiaoguanId));
    }

    /**
     * 新增土地浇灌
     */
    @PreAuthorize("@ss.hasPermi('system:tudijiaoguan:add')")
    @Log(title = "土地浇灌", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tudijiaoguan tudijiaoguan)
    {
        return toAjax(tudijiaoguanService.insertTudijiaoguan(tudijiaoguan));
    }

    /**
     * 修改土地浇灌
     */
    @PreAuthorize("@ss.hasPermi('system:tudijiaoguan:edit')")
    @Log(title = "土地浇灌", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tudijiaoguan tudijiaoguan)
    {
        return toAjax(tudijiaoguanService.updateTudijiaoguan(tudijiaoguan));
    }

    /**
     * 删除土地浇灌
     */
    @PreAuthorize("@ss.hasPermi('system:tudijiaoguan:remove')")
    @Log(title = "土地浇灌", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tudijiaoguanIds}")
    public AjaxResult remove(@PathVariable Long[] tudijiaoguanIds)
    {
        return toAjax(tudijiaoguanService.deleteTudijiaoguanByTudijiaoguanIds(tudijiaoguanIds));
    }
}
